package Schema::Result::Identity;

use strict;
use warnings;
use utf8;

use base qw/DBIx::Class::Core/;

__PACKAGE__->table('Identity');
__PACKAGE__->add_columns( 
    Id => { data_type => 'integer', is_auto_increment => 1 }, 
    ProjectId => {},
    Name  => {},
    Type  => {},
    Comment  => {},
);
__PACKAGE__->set_primary_key('Id');
__PACKAGE__->belongs_to(Project => 'Schema::Result::Project', 'ProjectId');

# 创建唯一标识
sub Create{
    my ($class, $schema, $params) = @_;

    my $newIdentity = $schema->resultset('Identity')->create($params);

    return $newIdentity;
}

# 修改唯一标识
sub Modify{
    my ($self, $type, $comment) = @_;
    if(defined $type){
        $self->Type($type);
    }
    if(defined $comment) {
        $self->Comment($comment);
    }

    $self->update;
}

# 删除
sub Delete {
    my ($self) = @_;

    $self->delete;
}

1;
